//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for TimestreamWrite
public struct TimestreamWriteErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case conflictException = "ConflictException"
        case internalServerException = "InternalServerException"
        case invalidEndpointException = "InvalidEndpointException"
        case rejectedRecordsException = "RejectedRecordsException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceQuotaExceededException = "ServiceQuotaExceededException"
        case throttlingException = "ThrottlingException"
        case validationException = "ValidationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize TimestreamWrite
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// You are not authorized to perform this action.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// Timestream was unable to process this request because it contains resource that already exists.
    public static var conflictException: Self { .init(.conflictException) }
    ///  Timestream was unable to fully process this request because of an internal server error.
    public static var internalServerException: Self { .init(.internalServerException) }
    /// The requested endpoint was invalid.
    public static var invalidEndpointException: Self { .init(.invalidEndpointException) }
    ///  WriteRecords would throw this exception in the following cases:     Records with duplicate data where there are multiple records with the same dimensions, timestamps, and measure names but different measure values.     Records with timestamps that lie outside the retention duration of the memory store     Records with dimensions or measures that exceed the Timestream defined limits.     For more information, see Access Management in the Timestream Developer Guide.
    public static var rejectedRecordsException: Self { .init(.rejectedRecordsException) }
    /// The operation tried to access a nonexistent resource. The resource might not be specified correctly, or its status might not be ACTIVE.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    ///  Instance quota of resource exceeded for this account.
    public static var serviceQuotaExceededException: Self { .init(.serviceQuotaExceededException) }
    ///  Too many requests were made by a user exceeding service quotas. The request was throttled.
    public static var throttlingException: Self { .init(.throttlingException) }
    ///  Invalid or malformed request.
    public static var validationException: Self { .init(.validationException) }
}

extension TimestreamWriteErrorType: Equatable {
    public static func == (lhs: TimestreamWriteErrorType, rhs: TimestreamWriteErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension TimestreamWriteErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
